package com.xidian.yunwudemo.service.impl;


import com.xidian.yunwudemo.dto.DataViewOverViewDto;
import com.xidian.yunwudemo.entities.PieBasicEntity;
import com.xidian.yunwudemo.mapper.master.DataAdaptiveMapper;
import com.xidian.yunwudemo.mapper.master.DataBioAuthMapper;
import com.xidian.yunwudemo.mapper.master.DataUserAuthMapper;
import com.xidian.yunwudemo.service.DataViewOverviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DataViewOverviewServiceImpl implements DataViewOverviewService {
    @Autowired
    DataBioAuthMapper dataBioAuthMapper;

    @Autowired
    DataUserAuthMapper dataUserAuthMapper;

    @Autowired
    DataAdaptiveMapper dataAdaptiveMapper;

    @Override
    public DataViewOverViewDto getOverviewData() {
        int bioCount = dataBioAuthMapper.countAll();
        int userCount = dataUserAuthMapper.countAll();
        int adaptiveCount = dataAdaptiveMapper.countAll();
        int countAll = bioCount + userCount + adaptiveCount;
        // metricsValue 不自己算了，直接写死，太折磨了
        String[] metricsValue = new String[]{"800ms","200ms","12/12","99%"};
        PieBasicEntity[] pieNum = new PieBasicEntity[3];
        pieNum[0] = new PieBasicEntity(adaptiveCount,"自适应认证");
        pieNum[1] = new PieBasicEntity(userCount,"用户认证");
        pieNum[2] = new PieBasicEntity(bioCount,"生物认证");

        return new DataViewOverViewDto(countAll,metricsValue,pieNum);
    }
}
